package com.css.ids.server.ticket;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.css.util.Md5Util;


public class Ticket {
	private long time;
	private String remark;
	private String flag;
	public Ticket(String key) {
		this.flag = key.substring(0,32);
		this.time = Long.parseLong(key.substring(32,45));
		if(key.length()>45){
			this.remark = key.substring(45);
		}
	}
	public long getTime() {
		return time;
	}
	public String getTimeStr() {
		return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(time));
	}
	public String getRemark() {
		if(remark==null)return "";
		return remark;
	}
	public boolean isValid(){
		String flag = Md5Util.MD5Encode(this.getTime()+this.getRemark());
		return this.flag.equals(flag);
	}
	
}
